import 'package:flutter/material.dart';
import 'PopupMenuButtonDemo.dart';
import 'FormDemo.dart';
import 'CheckBoxDemo.dart';
import 'RadioDemo.dart';
import 'SwitchDemo.dart';
import 'SliderDemo.dart';
import 'DateTimeDemo.dart';
import 'SimpleDialogDemo.dart';
import 'AlertDialogDemo.dart';
import 'BottomSheetDemo.dart';
import 'SnackBarDemo.dart';
import 'ExpansionPanelDemo.dart';

class MaterialComponents extends StatelessWidget {
  final Widget _floatingActionButton = FloatingActionButton(
    onPressed: () {},
    child: Icon(Icons.add),
    elevation: 0.0,
  );

  final Widget _floatingActionButtonExtended = FloatingActionButton.extended(
    onPressed: () {},
    icon: Icon(Icons.add),
    label: Text('Add'),
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('MaterialComponents'),
        elevation: 0.0,
      ),
      body: ListView(
        children: <Widget>[
          
          ListItem(
            title: 'ExpansionPanelDemo',
            page: ExpansionPanelDemo(),
          ),
          ListItem(
            title: 'SnackBarDemo',
            page: SnackBarDemo(),
          ),
          ListItem(
            title: 'BottomSheetDemo',
            page: BottomSheetDemo(),
          ),
          ListItem(
            title: 'AlertDialogDemo',
            page: AlertDialogDemo(),
          ),
          ListItem(
            title: 'SimpleDialogDemo',
            page: SimpleDialogDemo(),
          ),
          ListItem(
            title: 'DateTimeDemo',
            page: DateTimeDemo(),
          ),
          ListItem(
            title: 'SliderDemo',
            page: SliderDemo(),
          ),
          ListItem(
            title: 'SwitchDemo',
            page: SwitchDemo(),
          ),
          ListItem(
            title: 'RadioDemo',
            page: RadioDemo(),
          ),
          ListItem(
            title: 'CheckBoxDemo',
            page: CheckBoxDemo(),
          ),
          ListItem(
            title: 'FormDemo',
            page: FormDemo(),
          ),
          ListItem(
            title: 'ButtonDemo',
            page: ButtonDemo(),
          ),
          ListItem(
            title: 'SecondPage',
            page: SecondPage(),
          ),
          ListItem(
            title: 'PopupMenuButtonDemo',
            page: PopupMenuButtonDemo(),
          ),
        ],
      ),
      floatingActionButton: _floatingActionButton,
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      bottomNavigationBar: BottomAppBar(
        child: Container(
          height: 80.0,
        ),
        shape: CircularNotchedRectangle(),
      ),
    );
  }
}

class ButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final Widget _flatButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        FlatButton(
          child: Text('Button'),
          onPressed: null,
        ),
        FlatButton.icon(
          icon: Icon(Icons.add),
          label: Text('Add'),
          onPressed: () {},
          // splashColor: Colors.grey,
          splashColor: Theme.of(context).accentColor,
        )
      ],
    );

    final Widget _raisedButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Theme(
          data: Theme.of(context).copyWith(
              buttonColor: Theme.of(context).accentColor,
              buttonTheme: ButtonThemeData(
                textTheme: ButtonTextTheme.primary,
                // shape: BeveledRectangleBorder(
                //   borderRadius: BorderRadius.circular(5.0),
                // ),
                shape: StadiumBorder(),
              )),
          child: RaisedButton(
            child: Text('Button'),
            onPressed: () {},
            elevation: 0.0,
            // color: Theme.of(context).accentColor,
            // textColor: Colors.white,
            // textTheme: ButtonTextTheme.primary,
          ),
        ),
        SizedBox(
          width: 10.0,
        ),
        RaisedButton.icon(
          icon: Icon(Icons.add),
          label: Text('Add'),
          onPressed: () {},
          // splashColor: Colors.grey,
          elevation: 0.0,
          splashColor: Theme.of(context).accentColor,
        )
      ],
    );

    final Widget _outlineButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Theme(
          data: Theme.of(context).copyWith(
            buttonColor: Theme.of(context).accentColor,
            buttonTheme: ButtonThemeData(
              textTheme: ButtonTextTheme.primary,
              // shape: BeveledRectangleBorder(
              //   borderRadius: BorderRadius.circular(5.0),
              // ),
              shape: StadiumBorder(),
            ),
          ),
          child: OutlineButton(
            child: Text('Button'),
            onPressed: () {},
            // color: Theme.of(context).accentColor,
            // textColor: Colors.white,
            // textTheme: ButtonTextTheme.primary,
            borderSide: BorderSide(
              color: Colors.blueGrey,
            ),
            textColor: Colors.black,
            highlightedBorderColor: Colors.grey,
          ),
        ),
        SizedBox(
          width: 10.0,
        ),
        OutlineButton.icon(
          icon: Icon(Icons.add),
          label: Text('Add'),
          onPressed: () {},
          // splashColor: Colors.grey,
          splashColor: Theme.of(context).accentColor,
        )
      ],
    );

    final Widget _fixedWidthButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Container(
          width: 160.0,
          child: OutlineButton.icon(
            icon: Icon(Icons.add),
            label: Text('Add'),
            onPressed: () {},
            // splashColor: Colors.grey,
            splashColor: Theme.of(context).accentColor,
          ),
        )
      ],
    );

    final Widget _expandedWidthButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Expanded(
          child: OutlineButton(
            child: Text('Add'),
            onPressed: () {},
            // splashColor: Colors.grey,
            splashColor: Theme.of(context).accentColor,
          ),
        ),
        SizedBox(
          width: 10.0,
        ),
        Expanded(
          flex: 2,
          child: OutlineButton(
            child: Text('Add'),
            onPressed: () {},
            // splashColor: Colors.grey,
            splashColor: Theme.of(context).accentColor,
          ),
        ),
        SizedBox(
          width: 10.0,
        ),
        Expanded(
          flex: 1,
          child: OutlineButton(
            child: Text('Add'),
            onPressed: () {},
            // splashColor: Colors.grey,
            splashColor: Theme.of(context).accentColor,
          ),
        ),
      ],
    );

    final Widget _buttonBarDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Theme(
          data: Theme.of(context).copyWith(
            buttonTheme: ButtonThemeData(
              padding: EdgeInsets.symmetric(horizontal: 10.0),
            ),
          ),
          child: ButtonBar(
            children: <Widget>[
              OutlineButton(
                child: Text('Add'),
                onPressed: () {},
                // splashColor: Colors.grey,
                splashColor: Theme.of(context).accentColor,
              ),
              OutlineButton(
                child: Text('Add'),
                onPressed: () {},
                // splashColor: Colors.grey,
                splashColor: Theme.of(context).accentColor,
              ),
              OutlineButton(
                child: Text('Add'),
                onPressed: () {},
                // splashColor: Colors.grey,
                splashColor: Theme.of(context).accentColor,
              )
            ],
          ),
        )
      ],
    );

    return Scaffold(
      appBar: AppBar(
        title: Text('ButtonDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(10.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            _flatButtonDemo,
            _raisedButtonDemo,
            _outlineButtonDemo,
            _fixedWidthButtonDemo,
            _expandedWidthButtonDemo,
            _buttonBarDemo,
          ],
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SecondPage'),
      ),
      body: Container(),
    );
  }
}

class ListItem extends StatelessWidget {
  final String title;
  final Widget page;

  ListItem({
    this.title,
    this.page,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      child: ListTile(
        title: Text(title),
        onTap: () {
          Navigator.of(context).push(MaterialPageRoute(
            builder: (context) => page,
          ));
        },
      ),
    );
  }
}
